/** @format */

import * as Koa from 'koa';
import * as KoaBody from 'koa-body'
import {userRouter} from './api/user';
import {adminRouter} from './api/admin';
import * as serve from 'koa-static'
import * as history from 'koa2-history-api-fallback'
import {config} from './config';
const app = new Koa();

app.use(
  KoaBody({   
    multipart: true,
    formidable: {
      maxFileSize: 10 * 1024 * 1024, // 设置上传文件大小最大限制，默认2M
    },
  }),
);

app.use(userRouter.routes());
app.use(adminRouter.routes());

app.use(history());
// static files
app.use(serve(config.staticPath));

app.listen(3001);

console.log('Server running on port 3001');
